<div class="main_content">
   <h3 class="atitle"><?=$l_received_document ?> &rarr; <?=$l_approved_document ?></h3>
    <table class="tcontent" cellpadding="5" cellspacing="0">
        <tr class="trtit">
            <td width="20%"><a href=""><?=$l_document_form?></a></td>
            <td><a href=""><?=$l_title?></a></td>
            <td width="15%"><a href=""><?=$l_writer?></a></td>
            <td width="15%"><a href=""><?=$l_created_date?></a></td>
        </tr>
        <?php
			include 'operations/connection.php';
			$_SESSION['action'] = "re_approved";
		    if(array_key_exists("page",$_GET))
		        $page  = $_GET['page'];
		    else
		        $page = 1;
		    
		    mysql_select_db("elihan") or die ("Fail");
		    $abc = ($page-1)*10;
		    $query  = mysql_query("SELECT a.IDApproveDoc,e.FullName,a.Tile,a.Timecreate,a.IDTypeDoc FROM approvedoc a INNER JOIN listapprove b
				ON a.IDGroupApprove = b.IDGroupApprove INNER JOIN employee e ON a.IDEmployee = e.IDEmployee
				WHERE CONVERT(b.IDEmployee USING UTF8) = CONVERT( '$id_employee' USING UTF8)
				AND CONVERT(a.IDTypeDoc USING UTF8) != 11
				AND CONVERT(a.IDStatus USING UTF8) = 1
				AND CONVERT(b.IDStatus USING UTF8) = 1");
		    while ($row=mysql_fetch_array($query)):
			    if($row[IDTypeDoc]==7)$document = 		$l_vacation_form;
			    else if($row[IDTypeDoc]==12)$document = $l_assignment_report;
			    else if($row[IDTypeDoc]==13)$document = $l_purchase_order;
			    else if($row[IDTypeDoc]==14)$document = $l_daily_report;
			    else if($row[IDTypeDoc]==15)$document = $l_business_trip_report;
			    else if($row[IDTypeDoc]==16)$document = $l_weekly_report;
			    else if($row[IDTypeDoc]==17)$document = $l_susqence_payment_request;
		        echo "<tr><td>$document</td><td><a href='view.php?id=$row[IDApproveDoc]&type=$row[IDTypeDoc]'>$row[Tile]</a></td><td>$row[FullName]</td><td>$row[Timecreate]</td></tr>";
		    endwhile;
		?>
        <tr class="trfoo">
        	<td colspan="6">
            	<select id="paging">
					<?php
					    $query  = mysql_query("SELECT count(a.IDApproveDoc) as 'num' FROM approvedoc a INNER JOIN listapprove b
							ON a.IDGroupApprove = b.IDGroupApprove INNER JOIN employee e ON a.IDEmployee = e.IDEmployee
							WHERE CONVERT(b.IDEmployee USING UTF8) = CONVERT('$id_employee'  USING UTF8)
							AND CONVERT(a.IDTypeDoc USING UTF8) != 11
							AND CONVERT(a.IDStatus USING UTF8) = 1
							AND CONVERT(b.IDStatus USING UTF8) = 1");
					    $row = mysql_fetch_array($query);
					    $max = intval($row['num'])/10;
					    if($max > intval($max))
					    {
					        $max = intval($max)+1;
					    }
					    
					    echo "<option>$row[num]</option>"
					?>
				</select>
            </td>
        </tr>
    </table>
    
    <?php mysql_close($connection);?>
    <script type="text/javascript">
	    $(document).ready( function(){ 
	        $('#paging').val(<?php echo "$page" ?>); 
	        $('#paging').change(function(){ 
	           window.location = "list-receiver-not-approved.php?page="+$('#paging').val();  
	        }); 
	    });
    </script>
</div>